home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 4
/
FM Towns Free Software Collection 4 - Disc 1.iso
/
t_os
/
tmdsp
/
tbox.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-10-18
|
2KB
|
98 lines
/*
TBOX.C Ver 0.02 1991.08.09 by Y.Kurihara (Nif PDC01620)"
T-MENU の画面にちょっかいを出すプログラム その4
(1) TBOX <X座標> <Y座標> <桁数> <行数> [TYPE]
(1) 指定範囲に枠をかく
*/
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <machine.h>
#define X0 (2)
#define Xl (76)
#define Y0 (7)
#define Yl (20)
#define VRAM( offset ) ( (char far *)MK_FP( 0xc000,( offset ) ) )
#define PORTpage (0xff83)
#define PORTplane (0xff81)
#define Y1page (256)
extern int boxcnt;
extern char *boxbit[];
void box_part( int x1,int y1,int x2,char *bit )
{
unsigned int x,y;
unsigned int off;
if( y1 < Y1page ) {
outp( PORTpage, 0x00 );
off = y1 * 128;
} else {
outp( PORTpage, 0x10 );
off = ( y1 - Y1page )* 128;
}
for( y = 0; y < 8; y++ ) {
*VRAM( off + x1 ) = ~ bit[0];
for( x = x1 + 1; x < x2; x++ )
*VRAM( off + x ) = ~ bit[1];
*VRAM( off + x2 ) = ~ bit[2];
off += 128;
bit +=3;
}
return;
}
void box( int x1,int y1,int x2,int y2,int n )
{
int y;
char *bit;
bit = boxbit[n];
box_part( x1,y1 * 16 + 8,x2,bit );
for( y = y1 + 1; y < y2; y++ ) {
box_part( x1,y * 16 ,x2,bit + 24 );
box_part( x1,y * 16 + 8,x2,bit + 24 );
}
box_part( x1,y2 * 16,x2,bit + 48 );
return;
}
main( int argc,char **argv )
{
int save_page;
int save_plane;
int x1 = X0;
int y1 = Y0;
int x2 = Xl;
int y2 = Yl;
int n = 0;
if( argc >= 2 ) x1 = atoi( argv[1] );
if( argc >= 3 ) y1 = atoi( argv[2] );
if( argc >= 4 ) x2 = atoi( argv[3] );
if( argc >= 5 ) y2 = atoi( argv[4] );
if( argc >= 6 ) n = atoi( argv[5] );
if( x1 < 0 || y1 < 0 || x2 < 3 || y2 < 3 ) exit(1);
if( x1 >= 80 || y1 >= 30 ) exit(1);
if( ( x2 = x1 + x2 - 1 ) >= 80 ) x2 = 79;
if( ( y2 = y1 + y2 - 1 ) >= 30 ) y2 = 29;
if( n < 0 || n >= boxcnt ) n = 0;
save_page = inp( PORTpage );
save_plane = inp( PORTplane );
outp( PORTplane,15 );
box( x1,y1,x2,y2,n );
outp( PORTpage, save_page );
outp( PORTplane, save_plane );
exit( 0 );
}